package cn.yuanqiao.web.controller.archive.storeRoom;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.storeRoom.domain.BoxRecord;
import cn.yuanqiao.archive.storeRoom.service.IBoxRecordService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 档案盒记录Controller
 * 
 * @author xy
 * @date 2023-07-08
 */
@RestController
@RequestMapping("/archive/boxRecord")
public class BoxRecordController extends BaseController
{
    @Autowired
    private IBoxRecordService boxRecordService;

    /**
     * 查询档案盒记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:archiveBoxRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoxRecord boxRecord)
    {
        startPage();
        List<BoxRecord> list = boxRecordService.selectBoxRecordList(boxRecord);
        return getDataTable(list);
    }

    /**
     * 导出档案盒记录列表
     */
/*
    @PreAuthorize("@ss.hasPermi('storeRoom:BoxRecord:export')")
*/
    @Log(title = "档案盒记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoxRecord boxRecord)
    {
        List<BoxRecord> list = boxRecordService.selectBoxRecordList(boxRecord);
        ExcelUtil<BoxRecord> util = new ExcelUtil<BoxRecord>(BoxRecord.class);
        util.exportExcel(response, list, "档案盒记录数据");
    }

    /**
     * 获取档案盒记录详细信息
     */
/*
    @PreAuthorize("@ss.hasPermi('storeRoom:BoxRecord:query')")
*/
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(boxRecordService.selectBoxRecordById(id));
    }

    /**
     * 新增档案盒记录
     */

    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:archiveBoxRecord:add')")
    @Log(title = "档案盒记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoxRecord boxRecord)
    {
        return toAjax(boxRecordService.insertBoxRecord(boxRecord));
    }

    /**
     * 修改档案盒记录
     */
/*
    @PreAuthorize("@ss.hasPermi('storeRoom:BoxRecord:edit')")
*/
    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:archiveBoxRecord:edit')")
    @Log(title = "档案盒记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoxRecord boxRecord)
    {
        return toAjax(boxRecordService.updateBoxRecord(boxRecord));
    }

    /**
     * 删除档案盒记录
     */
    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:archiveBoxRecord:delete')")
    @Log(title = "档案盒记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boxRecordService.deleteBoxRecordByIds(ids));
    }
}
